package de.grosjohann.android.feuerwehr.webservice;

import java.io.IOException;

import org.apache.http.HttpException;
import org.apache.http.client.ClientProtocolException;

import android.content.Context;
import de.grosjohann.android.feuerwehr.R;
import de.grosjohann.android.feuerwehr.util.PrefsUtil;

public class CalendarWsFacade
  extends AbstractWsFacade {

  public static String getCalendar(Context ctx) throws ClientProtocolException, IOException, HttpException {
    final String wsUri = "/dienst";

    WsClient client = createClient(ctx, baseUri + wsUri);
    return client.get();
  }

  private static WsClient createClient(Context ctx, String uri) throws ClientProtocolException, IOException {
    final int connectionTimeout =
        PrefsUtil.getInt(ctx, R.string.prefKeyConnectionTimeout, R.string.prefDefaultConnectionTimeout);
    final int socketTimeout = PrefsUtil.getInt(ctx, R.string.prefKeySocketTimeout, R.string.prefDefaultSocketTimeout);

    return new WsClient(uri, connectionTimeout, socketTimeout);
  }
}
